<template>
  <div class="register">
    <div class="logo">
      <img src="../static/images/logo.png" alt="" />
    </div>

    <div class="form_container">
      <van-form>
        <van-field
          class="login_field"
          v-model="user_tel"
          name="user_tel"
          placeholder="手机号"
          :rules="[
            { required: true, message: '请填写手机号' },
            { validator: true, message: '请输入正确手机号' },
          ]"
        />
        <van-field
          v-model="sms"
          center
          clearable
          placeholder="请输入短信验证码"
          class="sendVal"
        >
          <template #button>
            <van-button size="small" type="primary">发送验证码</van-button>
          </template>
        </van-field>
        <div class="enter_button">
          <img src="../static/images/enter_button.png" alt="" />
          <van-button
            round
            block
            type="info"
            native-type="submit"
            @click="registerTwo"
            >提交
          </van-button>
        </div>
      </van-form>
    </div>
    <div class="foot">
      <div class="login_click">
        <van-checkbox v-model="checked">同意协议</van-checkbox>
      </div>
      <div @click="login" class="foot_right">我要登录</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      user_tel: "",
      checked: false,
      sms: "",
    };
  },
  methods: {
    validator(val) {
      return /1\d{10}/.test(val);
    },
    login() {
      this.$router.push({ path: "/login" });
    },
    registerTwo() {
      if (this.checked) {
        this.$router.push({
          path: "/registerTwo",
          query: {
            user_tel: this.user_tel,
          },
        });
      } else {
        return this.$toast("请勾选协议!");
      }
    },
  },
};
</script>
<style lang="less" scoped>
.register {
  width: 750rpx;
  height: 100%;

  .logo {
    padding: 16.7% 0 8.6%;
    width: 69.3%;
    height: 13.2%;
    margin: 0 auto;
  }

  .logo img {
    width: 100%;
    height: 100%;
  }

  .form_container {
    width: 65.2%;
    height: 27.3%;
    margin: 0 auto;
  }

  .enter_button {
    box-sizing: border-box;
    position: relative;
    padding: 8% 0 0 0;
    width: 22.4%;
    height: 24.7%;
    margin: 0 auto;
    display: block;
  }

  .enter_button button {
    background: none;
    border: none;
    border-radius: 50%;
    font-size: 0;
  }

  .enter_button > img {
    position: absolute;
    width: 100%;
    top: 24.7%;
    left: 0;
  }

  .form_container .login_field,
  .form_container .register_field:not(.security_code) {
    box-sizing: border-box;
    width: 100%;
    height: 18.5%;
    // padding: 6% 0 0 8%;
    margin-bottom: 14.9%;
    background-color: rgb(244, 244, 244);
    border-radius: 59px;
  }

  .van-field__body {
    height: 37.3%;
    align-items: baseline;
  }

  .van-field__control::-webkit-input-placeholder {
    color: rgb(144, 144, 144);
    font-family: "Adobe Heiti Std";
  }

  .foot {
    position: fixed;
    width: 70.9%;
    padding: 0 14%;
    bottom: 7.5%;
    font-family: "SourceHanSansCN";
    font-weight: 600;
    font-size: 0.5em;
  }

  .foot .login_click {
    float: left;
  }

  .foot_right {
    float: right;
  }

  .security_code {
    position: relative;
    width: 61%;
    margin: 0 0 14.9% 0;
    border-radius: 59px;
    width: 60.6%;
    background-color: rgb(244, 244, 244);
  }
  .van-button--primary {
    position: absolute;
    right: -100px;
    background-color: transparent;
    border: none;
    color: rgb(186, 131, 104);
    font-family: "SourceHanSansCN";
    font-weight: 500;
  }

  .foot .van-radio__icon .van-icon {
    width: 0.9em;
    height: 0.9em;
  }
  .agreement .van-radio__label {
    vertical-align: text-bottom;
  }
}
</style>